package com.Apo1o.controller;

import com.Apo1o.bean.ManagerFenceHouse;
import com.Apo1o.response.Result;
import com.Apo1o.service.IFenceHouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther: Apo1o.
 * @Date: 2023/10/31-10-31-21:47
 * @Description： com.Apo1o.controller
 */
@Api(tags = "swagger测试")
@RestController
@RequestMapping("swagger")
@RequiredArgsConstructor
public class FenceSwaggerController {

    private final IFenceHouseService iFenceHouseService;
    @ApiOperation(notes = "分页的参数必须得传，没有fhName就是查所有的",value = "分页和关键字")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "页码",required = true, paramType = "query", dataType = "Integer") ,
            @ApiImplicitParam(name = "pageSize",value = "页大小",required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "fhName",value = "fhName",required = false, paramType = "query", dataType = "String")
                    })
    @GetMapping("query")
    public Result query(Integer pageNum, Integer pageSize, String fhName){

        return Result.success(iFenceHouseService.query(pageNum,pageSize,fhName));
    }
    @DeleteMapping("deleteById/{id}")
    public Result deleteById(@PathVariable String id){
        iFenceHouseService.deleteById(id);
        return Result.success("删除成功");
    }
    @DeleteMapping("deleteByIdAll")
    public Result deleteByIdAll(@RequestBody List<String> list){
        iFenceHouseService.deleteByBatch(list);
        return Result.success("删除成功");
    }
    @PostMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody ManagerFenceHouse managerFenceHouse){
        iFenceHouseService.saveOrUpdate(managerFenceHouse);
        System.out.println(managerFenceHouse);
        return Result.success();
    }
    @GetMapping("selectById")
    public Result selectById(String hId){
        return Result.success(  iFenceHouseService.selectById(hId));
    }


}
